using System;
using TagTool.GraphicTypes;
using TagTool.Devices.DataStructures;
	
namespace TagTool.Devices
{
    /// <summary> Represents arguments for input devices </summary>
    public abstract class InputDeviceEventArgs : EventArgs
    {
    }

    /// <summary> Represents arguments for pointing devices </summary>
    public class PointingDeviceEventArgs : InputDeviceEventArgs
    {
        /// <summary> Identifies button </summary>
        private uint buttons;
        private PointD location;

        public PointingDeviceEventArgs()
        {
            location = new PointD();
        }

        public PointingDeviceEventArgs(uint buttons, PointD location)
        {
            this.buttons = buttons;
            this.location = location;
        }

        public uint Buttons
        {
            get
            {
                return buttons;
            }
            set
            {
                buttons = value;
            }
        }

        public double X
        {
            get
            {
                return location.X;
            }
            set
            {
                location.X = value;
            }
        }

        public double Y
        {
            get
            {
                return location.Y;
            }
            set
            {
                location.Y = value;
            }
        }

        public double Z
        {
            get
            {
                return location.Z;
            }
            set
            {
                location.Z = value;
            }
        }

        public PointD Location
        {
            get
            {
                return location;
            }
            set
            {
                location = value;
            }
        }
    }

    public class JoystickDeviceEventArgs : PointingDeviceEventArgs
    {
    	private PointD rudder = new PointD();
		
		public JoystickDeviceEventArgs()
        {
        }

		public JoystickDeviceEventArgs(uint buttons, PointD location) : base(buttons, location)
        {
        }
		
		public JoystickDeviceEventArgs(uint buttons, PointD location, PointD rudder) : base(buttons, location)
        {
			this.rudder = rudder;
        }
		
		public PointD Rudder
		{
			get { return rudder; }
			set { rudder = value; }
		}
		
    }

    public class MouseDeviceEventArgs : PointingDeviceEventArgs
    {
        private uint clicks;

        public MouseDeviceEventArgs()
        {
        }

        public MouseDeviceEventArgs(uint buttons, uint clicks, PointD location)
            : base(buttons, location)
        {
            this.clicks = clicks;
        }

        public uint Clicks
        {
            get
            {
                return clicks;
            }
            set
            {
                clicks = value;
            }
        }
    }
    
    public class KeyboardDeviceEventArgs : InputDeviceEventArgs
    {
    	private int key = 0;
        private int time = 0;
        
        private bool altDown = false;
        private bool pressed = false;
        
    	public KeyboardDeviceEventArgs()
    	{
    	}
    	
    	public int Key
    	{
    		get {return key; }
    		set { key = value; }
    	}
  	  	
    	public int Time
    	{
    		get {return time; }
    		set { time = value; }
    	}
    	
   		public bool AltDown
   		{
   			get {return altDown; }
    		set { altDown = value; }
   		}
   		
   		public bool Pressed
   		{
   			get {return pressed; }
    		set { pressed = value; }
   		}
    }

    public class TabletEventArgs : EventArgs
    {
        string message;
        uint context;

        public TabletEventArgs(string message, uint context)
        {
            this.message = message;
            this.context = context;
        }

        public string Message
        {
            get
            {
                return message;
            }
        }

        public uint Context
        {
            get
            {
                return context;
            }
        }
    }

    /// <summary> Represents cursor event arguments </summary>
    public class CursorDeviceEventArgs : PointingDeviceEventArgs
    {
        /// <summary> The id of the device </summary>
        private uint deviceId;
        /// <summary> Context of message </summary>
        private uint context;
        /// <summary> Specifies the normal pressure put on the cursor </summary>
        private uint normalPressure;
        /// <summary> Specifies the tangent pressure put on the cursor </summary>
        private uint tangentPressure;
        /// <summary> Orientation (altitude, azimuth and twist) of the cursor </summary>
        private Orientation orientation;

        /// <summary> Standard constructor </summary>
        public CursorDeviceEventArgs()
        {
            orientation = new Orientation();
        }

        /// <summary> Constructor. Initializes members </summary>
        /// <param name="deviceId"> The id of the device </param>
        /// <param name="context"> The context of the cursor </param>
        /// <param name="button"> The button that was pressed </param>
        /// <param name="x"> X coordinate of the cursor </param>
        /// <param name="y"> Y coordinate of the cursor </param>
        /// <param name="pressure"> Pressure put on the cursor </param>
        public CursorDeviceEventArgs(uint deviceId, uint context, uint button, PointD location, uint normalPressure, uint tangentPressure, Orientation orientation)
            : base(button, location)
        {
            this.normalPressure = normalPressure;
            this.tangentPressure = tangentPressure;
            this.orientation = orientation.Clone();
        }

        #region Properties

        /// <summary> Property DeviceId </summary>
        public uint DeviceId
        {
            get
            {
                return deviceId;
            }
            set
            {
                deviceId = value;
            }

        }

        /// <summary> Property Context </summary>
        public uint Context
        {
            get
            {
                return context;
            }
            set
            {
                context = value;
            }
        }

        /// <summary> Property NormalPressure </summary>
        public uint NormalPressure
        {
            get
            {
                return normalPressure;
            }
            set
            {
                normalPressure = value;
            }
        }

        /// <summary> Property TangentPressure </summary>
        public uint TangentPressure
        {
            get
            {
                return tangentPressure;
            }
            set
            {
                tangentPressure = value;
            }
        }

        /// <summary> Property TangentPressure </summary>
        public Orientation Orientation
        {
            get
            {
                return orientation;
            }
            set
            {
                orientation = value.Clone();
            }
        }

        #endregion
    }

    public class ContextEventArgs : EventArgs
    {
        private uint contextId;
        private uint area;

        public ContextEventArgs()
        {
        }

        public ContextEventArgs(uint contextId, uint area)
        {
            this.contextId = contextId;
            this.area = area;
        }

        public uint ContextId
        {
            get
            {
                return contextId;
            }
        }
    }
}
